package com.apes.scm.masterdata.party.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.area.model.Area;
import com.apes.scm.masterdata.area.model.Country;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：供应商发货点
 *
 * @author Linwz
 * @create 2020-2-13 11:23
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = SupplierShipItem.CONST_TABLE_NAME)
public class SupplierShipItem extends BaseModel {
    public static final String CONST_TABLE_NAME = "mas_supplier_ship_item";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "供应商发货点编码")
    @Comment("供应商发货点编码")
    private String id;   //供应商发货点编码

    @ManyToOne(optional = false)
    @JoinColumn(name = "supplier_logistic_id", referencedColumnName = "id")
    @Comment("供应商物流扩展表")
    private SupplierLogistic supplierLogistic;

//    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "country_id", referencedColumnName = "id")
//    @Comment("国家")
//    private Country country; //国家

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "province_id", referencedColumnName = "id")
    @Comment("省份")
    private Area province; //省份

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "city_id", referencedColumnName = "id")
    @Comment("城市")
    private Area city; //城市

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "county_id", referencedColumnName = "id")
    @Comment("区县")
    private Area county; //区县

    @Column(name = "address", length = 500)
    @Comment("详细地址")
    @Name
    private String address; //详细地址

    @Name
    @Column(name = "contact", length = 256)
    @Comment("联系人")
    private String contact;  //联系人

    @Name
    @Column(name = "phone", length = 256)
    @Comment("联系电话")
    private String phone;  //联系电话

    @Column(name = "longitude", columnDefinition = ApesConst.FIELD_16_4_0)
    @Comment("经度")
    private double longitude = 0.0;  //经度

    @Column(name = "latitude", columnDefinition = ApesConst.FIELD_16_4_0)
    @Comment("纬度")
    private double latitude = 0.0;  //纬度

}
